home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / GX Libraries / SelectionLibrary.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-31  |  3.4 KB  |  131 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SelectionLibrary.h
  3.     
  4.     Contains:    layout library interface: Routines to manipulate Selection objects
  5.     
  6.     Written By:    Dave Opstad, Eric Mader
  7.     
  8.     Copyright:    ©1992-1995 by Apple Computer, Inc.  All rights reserved.
  9.     
  10.     Change History (most recent first):
  11.     
  12.          <2>      1/9/95    JD        changed 'boolean' to 'Boolean'
  13.          <1>      1/9/95    JD        First checked in.
  14.  
  15. */
  16.  
  17. #ifndef __SELECTIONLIBRARY__
  18. #define __SELECTIONLIBRARY__
  19.  
  20. #include <GXTypes.h>
  21.  
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25.  
  26. /* for compatibility with old headers */
  27. #define selectionLibraryIncludes
  28.  
  29. /* Constants and Enumerations */
  30.  
  31. #define selectionExtremeEdge -1
  32.  
  33. enum SelectionTypes {
  34.   emptySelection,
  35.   simpleCaret,
  36.   simpleRange,
  37.   discontiguousRange
  38. };
  39. typedef unsigned short SelectionType;
  40.  
  41. enum SelectionMatches {
  42.   notInSelection,
  43.   partlyInSelection,
  44.   fullyInSelection,
  45.   equalToSelection
  46. };
  47. typedef unsigned short SelectionMatch;
  48.  
  49. /* Types and Structures */
  50.  
  51. typedef long SelectionOffset;
  52.  
  53. struct SelectionOffsetRange {
  54.   SelectionOffset minOffset;  /* earliest char */
  55.   SelectionOffset maxOffset;  /* latest char */
  56. };
  57. typedef struct SelectionOffsetRange SelectionOffsetRange;
  58.  
  59. struct SelectionRanges {
  60.   long                                                    rangeCount;
  61.   struct SelectionOffsetRange        ranges[gxAnyNumber];
  62. };
  63. typedef struct SelectionRanges SelectionRanges;
  64.  
  65. struct CaretPiece {
  66.   SelectionOffset                                offset;
  67.   short                                                    leadingEdge;
  68. };
  69. typedef struct CaretPiece CaretPiece;
  70.  
  71. struct Selection {
  72.     SelectionType    type;
  73.   union {
  74.     struct CaretPiece            caret;
  75.     struct SelectionRanges        range;
  76.     } data;
  77. };
  78. typedef struct Selection Selection;
  79.  
  80. typedef struct Selection* SelectionPtr, ** SelectionHandle;
  81.  
  82. /* Routines */
  83.  
  84. SelectionHandle NewEmptySelection(void);
  85. SelectionHandle NewCaretSelection(SelectionOffset offset, long leadingEdge);
  86. SelectionHandle NewRangeSelection(SelectionOffsetRange *range);
  87.  
  88. SelectionHandle NewFullSelection(void);
  89. SelectionHandle NewStartSelection(SelectionOffset toOffset);
  90. SelectionHandle NewEndSelection(SelectionOffset fromOffset);
  91.  
  92. void SetEmptySelection(SelectionHandle selection);
  93. void SetCaretSelection(SelectionHandle selection, SelectionOffset offset, long leadingEdge);
  94. void SetRangeSelection(SelectionHandle selection, SelectionOffsetRange *range);
  95.  
  96. void SetFullSelection(SelectionHandle selection);
  97. void SetStartSelection(SelectionHandle selection, SelectionOffset toOffset);
  98. void SetEndSelection(SelectionHandle selection, SelectionOffset fromOffset);
  99.  
  100. void DisposeSelection(SelectionHandle selection);
  101.  
  102. SelectionType GetSelectionType(SelectionHandle selection);
  103.  
  104. SelectionOffset GetCaretSelection(SelectionHandle selection, Boolean *leadingEdge);
  105. long GetRangeSelection(SelectionHandle selection, SelectionRanges *selectionRanges);
  106.  
  107. SelectionMatch RangeInSelection(SelectionHandle selection, SelectionOffsetRange *range);
  108.  
  109. void InvertSelection(SelectionHandle dest);
  110. void ShiftSelection(SelectionHandle dest, SelectionOffset delta);
  111.  
  112. void UnionSelection(SelectionHandle dest, SelectionHandle source);
  113. void SectSelection(SelectionHandle dest, SelectionHandle source);
  114. void XorSelection(SelectionHandle dest, SelectionHandle source);
  115. void DiffSelection(SelectionHandle dest, SelectionHandle source);
  116.  
  117. gxShape GetLayoutSelection(
  118.   gxShape           layout,
  119.   SelectionHandle selection,
  120.   SelectionOffset lineStart,
  121.   gxHighlightType   highlightType,
  122.   gxCaretType       caretType);
  123.  
  124. SelectionHandle NewDiscontiguousSelection(SelectionRanges *ranges);
  125.  
  126. #ifdef __cplusplus
  127. }
  128. #endif
  129.  
  130. #endif /* __SELECTIONLIBRARY__ */
  131.